<html>
<head><meta charset="utf-8"><title>Borrowing and automatic execution · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Borrowing.20and.20automatic.20execution.html">Borrowing and automatic execution</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="168391699"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Borrowing%20and%20automatic%20execution/near/168391699" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Papp <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Borrowing.20and.20automatic.20execution.html#168391699">(Jun 18 2019 at 11:39)</a>:</h4>
<p>So there is this example of borrowing -&gt; <a href="https://doc.rust-lang.org/beta/rust-by-example/scope/borrow.html" target="_blank" title="https://doc.rust-lang.org/beta/rust-by-example/scope/borrow.html">https://doc.rust-lang.org/beta/rust-by-example/scope/borrow.html</a> <code>fn borrow_i32(borrowed_i32: &amp;i32)</code> is getting called with a <code>&amp;Box&lt;i32&gt;</code> I guess the Borrow trait is responsible for turning the <code>&amp;Box&lt;i32&gt;</code> into and <code>&amp;i32</code>. If it is how does the compiler know that it has to use the method from this trait or from some other in case it's a different trait? I just have a hard time figuring out how these things work in Rust.</p>



<a name="168403165"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Borrowing%20and%20automatic%20execution/near/168403165" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Borrowing.20and.20automatic.20execution.html#168403165">(Jun 18 2019 at 13:56)</a>:</h4>
<blockquote>
<p>I guess the Borrow trait is responsible </p>
</blockquote>
<p>It is not. <a href="https://stackoverflow.com/q/28519997/155423" target="_blank" title="https://stackoverflow.com/q/28519997/155423">What are Rust's exact auto-dereferencing rules?</a> and <a href="https://doc.rust-lang.org/std/ops/trait.Deref.html" target="_blank" title="https://doc.rust-lang.org/std/ops/trait.Deref.html"><code>Deref</code></a>.</p>



<a name="168403352"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Borrowing%20and%20automatic%20execution/near/168403352" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Borrowing.20and.20automatic.20execution.html#168403352">(Jun 18 2019 at 13:58)</a>:</h4>
<p>Also, procedural aside: there's no problem with asking these types of questions here, but it's not the primary place for them, either. That's why responses are so slow. Regular "using Rust" questions are more frequent in the Discord or user's forum (<a href="https://www.rust-lang.org/community" target="_blank" title="https://www.rust-lang.org/community">https://www.rust-lang.org/community</a>). Zulip tends to be more heavily used by the people working on compiler and other "implementation details"</p>



<a name="168403382"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Borrowing%20and%20automatic%20execution/near/168403382" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Borrowing.20and.20automatic.20execution.html#168403382">(Jun 18 2019 at 13:59)</a>:</h4>
<p>So if you want responses any quicker, those might be better places :-)</p>



<a name="168407615"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Borrowing%20and%20automatic%20execution/near/168407615" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Papp <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Borrowing.20and.20automatic.20execution.html#168407615">(Jun 18 2019 at 14:44)</a>:</h4>
<p>Ah ok, I keep that in mind. Also thanks for the link.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>